import pymysql

db = pymysql.connect('localhost', 'root', '123456', 'hbooker',charset='utf8')

cursor = db.cursor()

sql = "SELECT * FROM hbooker.book"

try:
    cursor.execute(sql)
    results = cursor.fetchall()
    for row in results:
        title = row[0]
        author = row[1]
        clicktotal = row[2]
        print("title:%s,author:%s,clicktotal:%s" % (title, author, clicktotal))
except:
    print('hello')

db.close()
